<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .train1 {
            height: 100px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
        }

        .train1 span {
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            background-color: black;
            color: beige;
        }
    </style>
</head>

<body>
    <div class="train1">
        <span id="" num>1</span>
        <span onclick="add()">增加</span>
        <span onclick="sub()">减少</span>
    </div>
    <script>
        function add() {
            //获取到id是num中的数  
            let n = document.getElementById("num").innerText;
            n++;
            document.getElementById("num").innerText = n;
        }
        function sub() {
            let n = document.getElementById("num").innerText;
            n--;
            document.getElementById("num").innerText = n;

        }  
    </script>
</body>

</html>